//
//  AboutOurViewController.m
//  YouWen
//
//  Created by 刘永和 on 15/3/7.
//  Copyright (c) 2015年 刘永和. All rights reserved.
//

#import "AboutOurViewController.h"

@interface AboutOurViewController ()

@end

@implementation AboutOurViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    //切换按钮
    NSArray *array1 = [NSArray arrayWithObjects:@"新闻收藏", @"汽车收藏",  nil];
    self.segmentedControl = [[UISegmentedControl alloc] initWithItems:array1];
    
    self.navigationItem.titleView = self.segmentedControl;

    self.segmentedControl.selectedSegmentIndex = 2;//设置默认选择项索引
    self.segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;//设置样式
//    [self.segmentedControl setTitle:@"新闻收藏" forSegmentAtIndex:1];//设置指定索引的题目
    
  [self.segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    
    
    
    
    self.carCollectionVC = [[CarCollectionViewController alloc] init];
    [self addChildViewController:self.carCollectionVC];
    [self.view addSubview:self.carCollectionVC.view];
    
    
    self.newsCollectionVC = [[NewsCollectionViewController alloc] init];
    [self addChildViewController:self.newsCollectionVC];
    
    [self.view addSubview:self.newsCollectionVC.view];
    
    
    
    
    
    
    
}
- (void)segmentAction:(UISegmentedControl *)segment
{
    if (segment.selectedSegmentIndex ==  0) {
        [self.view addSubview:self.newsCollectionVC.view];
    }else if(segment.selectedSegmentIndex == 1){
        [self.view addSubview:self.carCollectionVC.view];
        
    }
    
    

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
